package club.justwill.single.helper;

import club.justwill.single.bean.GetProjectByTS;
import club.justwill.single.model.CoreConstants;
import club.justwill.single.model.JsonResponse;
import club.justwill.single.model.ProjectType;
import club.justwill.single.util.JsonResponseHelper;

/**
 * Created by luoyu on 2/25/16.
 */
public class ProjectHelp extends BaseHelper{
    public static boolean canSearchProject(JsonResponse obj, GetProjectByTS getProjectByTS) {
        int tag = getProjectByTS.getTag();
        int status = getProjectByTS.getStatus();
        boolean can = false;

        if(getProjectByTS.getIndex()<0) {
            JsonResponseHelper.addError(obj, CoreConstants.INDEX_ERROR);
        } else if (getProjectByTS.getSize()<=0) {
            JsonResponseHelper.addError(obj, CoreConstants.SIZE_ERROR);
        } else if (tag != ProjectType.TAG_AGRICULTURE
                && tag != ProjectType.TAG_ART
                && tag != ProjectType.TAG_COMMONWEAL
                && tag != ProjectType.TAG_ENTERTAINMENT
                && tag != ProjectType.TAG_TECHNOLOGY
                && tag != ProjectType.TAG_OTHER
                && tag != ProjectType.TAG_ALL
                && tag != ProjectType.TAG_PUBLISH){
            JsonResponseHelper.addError(obj, CoreConstants.TAG_ERROR);
        } else if (status != ProjectType.STATUS_PREHEAT
                && status != ProjectType.STATUS_CROW
                && status != ProjectType.STATUS_FINISH
                && status != ProjectType.STATUS_PAY_CUSTOMER
                && status != ProjectType.STATUS_PAY_MERCHANT) {
            JsonResponseHelper.addError(obj, CoreConstants.STATUS_ERROR);
        } else {
            can = true;
        }
        return can;
    }
}
